#!/usr/bin/python
# coding: utf-8
from sqlalchemy import *
from sqlalchemy.orm import *
import datetime
engine=create_engine("sqlite:///test.db",echo=True)
metadate=MetaData(engine)

users_table=Table('users',metadate,Column('id',Integer,primary_key=True),Column('name',String),Column('password',String))
#metadate.create_all(engine)
class user(object):
    def __init__(self,name='',password='',id=None):
        if id==None:
            id=100
        self.id=id
        self.name=name
        self.password=password
    def __repr__(self):
        return "<user('ID=%s,%s,%s')>" %(self.id,self.name,self.password)

mapper(user,users_table)

metadate.create_all()
insuser=user(83,'f','d')

s=Session()
s.add(insuser)
s.commit()
s.close()

ss=Session()
lists=ss.query(user).all()
ss.close()

rets=[]
for i in lists:
    if i.id==12:
        rets.append(i.name)
        rets.append(i.password)
        


